package com.zzyl.nursing.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;

import com.zzyl.nursing.domain.NursingTask;
import com.zzyl.nursing.dto.NursingTaskDto;
import com.zzyl.nursing.dto.NursingTaskExecuteDto;
import com.zzyl.nursing.dto.NursingTaskUpdateTimeDto;
import com.zzyl.nursing.vo.NursingTaskVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface NursingTaskMapper {

    List<NursingTask> list(NursingTaskDto dto);

    NursingTaskVo selectNursingTaskById(Integer id);
    
    /**
     * 插入护理任务
     */
    int insertNursingTask(NursingTask nursingTask);

    @Update("update nursing_task set status = 3,cancel_reason=#{cancelReason} where id = #{taskId}")
    void cancel(@Param("cancelReason") String reason, @Param("taskId") Integer taskId);

    @Update("update nursing_task set status = 2, estimated_server_time = #{executeDto.estimatedServerTime}, " +
            "mark = #{executeDto.mark}, task_image = #{executeDto.taskImage}, " +
            "real_server_time = NOW() where id = #{executeDto.taskId}")
    void execute(@Param("executeDto") NursingTaskExecuteDto executeDto);

    @Update("update nursing_task set estimated_server_time = #{updateTimeDto.estimatedServerTime} " +
            "where id = #{updateTimeDto.taskId}")
    void updateTime(@Param("updateTimeDto") NursingTaskUpdateTimeDto updateTimeDto);
}
